package com.jcal.librarymanager.dialogs;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

import com.jcal.librarymanager.R;
import com.jcal.librarymanager.fragments.FragmentListe;

public class Ajouter extends Dialog {

	public Ajouter(Context context) {
		super(context);
		
		setTitle(R.string.menu_action_ajouter);
		setContentView(R.layout.dialog_ajouter);
		
		final ImageView photo = (ImageView) findViewById(R.id.photo);
		EditText codeBarre = (EditText) findViewById(R.id.code_barre);
		final EditText nom = (EditText) findViewById(R.id.nom_editText);
		final EditText description = (EditText) findViewById(R.id.description_editText);
		Button ajouter = (Button) findViewById(R.id.ajouter);
		Button annuler = (Button) findViewById(R.id.annuler);
		
		ajouter.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				FragmentListe.addElement(R.drawable.ic_launcher, nom.getText().toString(), description.getText().toString());
				FragmentListe.refresh();
				dismiss();
			}
		});
		
		annuler.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				dismiss();
			}
		});
		
		
	}
}
